package com.junzhiit.nengji.cms.web.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.bainaeco.framework.util.AssertUtil;
import com.junzhiit.nengji.cms.service.RechargeConfigureService;
import com.junzhiit.nengji.cms.web.vo.DataTablesParamVO;
import com.junzhiit.nengji.cms.web.vo.RechargeConfigureVO;
import com.junzhiit.nengji.cms.web.vo.ResultVO;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/recharge/configure")
public class RechargeConfigureController extends BaseController {
	
	@Autowired
	private RechargeConfigureService rechargeConfigureService;
	
	@ApiOperation(value = "获取所有充值列表")
	@RequestMapping(value="/all",method = RequestMethod.GET)
	public Map<String, Object> findAll(RechargeConfigureVO vo,DataTablesParamVO dtp){
		
		return rechargeConfigureService.findAll(vo, dtp);
	}
	
	@ApiOperation(value = "获取所有充值列表")
	@RequestMapping(value="/{id}",method = RequestMethod.GET)
	public ResultVO findById(@PathVariable String id){
		return rechargeConfigureService.findById(id);
	}
	
	@ApiOperation(value = "添加一个充值赠送")
	@RequestMapping(method = RequestMethod.POST)
	public ResultVO add(RechargeConfigureVO vo){
		AssertUtil.notNull(vo.getRechargeMoney(), "rechargeMoney is required.");
		AssertUtil.notNull(vo.getGiveType(), "giveType is required.");
		return rechargeConfigureService.add(vo);
	}
	
	@ApiOperation(value = "修改一个充值赠送")
	@RequestMapping(method = RequestMethod.PUT)
	public ResultVO update(RechargeConfigureVO vo){
		AssertUtil.notBlank(vo.getId(), "ID is required.");
		return rechargeConfigureService.update(vo);
	}
	
	@ApiOperation(value = "删除一个充值赠送")
	@RequestMapping(value="/{id}",method = RequestMethod.DELETE)
	public ResultVO delete(@PathVariable String id){
		AssertUtil.notBlank(id, "ID is required.");
		return rechargeConfigureService.delete(id);
	}
	
}
